<template>	
	<view>
		<view
			class="list-cell b-b"
			:class="{ 'm-t': true }"
			@tap="handleCstm"
			hover-class="cell-hover"
			:hover-stay-time="50"
		>
			<text class="cell-tit">{{ cstmData.customName ? cstmData.customName : '--'  }}</text>
			<text class="cell-tip">{{ cstmData.sex == 0 ? '男' : cstmData.sex == 1 ? '女' : '--' }}</text>
			<text class="cell-more iconfont iconyou"></text>
		</view>	
										
		<block v-for="(item ,index) in info" :key="index" :style="{top: customBar +'px'}">
			<uni-card :title="item.title" :thumbnail="`${baseUrl}/appIcon/health/${item.images}`" bgcolor='#f7f7fa' :images="item.demo"  :note="item.tips | filterTime" @click="handleHistory($event,item)" :extra="item.extra  ">
				<!-- <text class="content-box-text">{{ item.texts }}</text> -->
				<!-- <view class="content-box-text" style="display: flex;flex-direction: column" v-html="item.texts"></view> -->
				<view class="uni-flex uni-column" v-html="item.texts" >
<!-- 				<view class="uni-flex uni-row"><text class="flex-item text-left">高压：</text> <text class="flex-item font-weight">${r.data.xieyaHigh == 0 ? '--' : r.data.xieyaHigh}</text> <text class="flex-item text-right"> mmHg</text></view>
				<view class="uni-flex uni-row"><text class="flex-item text-left">低压：</text> <text class="flex-item font-weight">${r.data.xieyaLow == 0 ? '--' : r.data.xieyaLow}</text><text class="flex-item text-right"> mmHg</text></view>
				<view class="uni-flex uni-row"><text class="flex-item text-left">脉搏：</text> <text class="flex-item font-weight>${r.data.maibo == 0 ? '--' : r.data.maibo}</text><text class="flex-item text-right "> 次/分</text></view> --> 	
							
				</view>
								
			</uni-card>
		</block>
	</view>
</template>

<script>
	import uniCard from '@/components/uni-card/uni-card.vue';
	import {getTodayJkzsItem, cstmDetail,getHealthParam} from '@/api/userInfo';
	import moment from '@/common/moment';
	export default {
		data() {
			return {
				cstmData : {},
				info: [],
			    userInfo : {},
				customBar: this.CustomBar,
				headImg : this.$mAssetsPath.headImg,
				baseUrl : this.$mConfig.baseUrl
				
				
			};
		},
		components: {
			uniCard			
		},
		filters:{
			filterType(val){
				if(val===1)
				  val = '饭前';
				else
				 val = '饭后';
				 
				return val;
			},
			filterTime(val){
				return val ? '最近测量：'+moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
			}
			
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.info = [];
			this.getAddressList('refresh');
		},
		onLoad(option) {
			this.source = option.source;
		},
		onShow() {
			this.initData();
		},
		methods: {
			// 获取用药提醒
			 getHealthParam() {
						 this.$http
							.get(`${getHealthParam}`)
							.then(async r => {
								//console.log("r.data: " + JSON.stringify(r.data));
								            uni.setStorageSync("XY_GY_MIN",ret.data.XY_GY_MIN);
											uni.setStorageSync("XY_GY_MAX",ret.data.XY_GY_MAX);
											uni.setStorageSync("XY_DY_MIN",ret.data.XY_DY_MIN);
											uni.setStorageSync("XY_DY_MAX",ret.data.XY_DY_MAX);
											uni.setStorageSync("MB_MIN",ret.data.MB_MIN);
											uni.setStorageSync("MB_MAX",ret.data.MB_MAX);
											uni.setStorageSync("XT_CH_MIN",ret.data.XT_CH_MIN);
											uni.setStorageSync("XT_CH_MAX",ret.data.XT_CH_MAX);
											uni.setStorageSync("XT_KF_MIN",ret.data.XT_KF_MIN);
											uni.setStorageSync("XT_KF_MAX",ret.data.XT_KF_MAX);
											uni.setStorageSync("XY_MIN",ret.data.XY_MIN);
											uni.setStorageSync("XY_MAX",ret.data.XY_MAX);
											uni.setStorageSync("TW_MIN",ret.data.TW_MIN);
											uni.setStorageSync("TW_MAX",ret.data.TW_MAX);
											uni.setStorageSync("NS_UMOL_MIN",ret.data.NS_UMOL_MIN);
											uni.setStorageSync("NS_UMOL_MAX",ret.data.NS_UMOL_MAX);
											uni.setStorageSync("DGC_MIN",ret.data.DGC_MIN);
											uni.setStorageSync("DGC_MAX",ret.data.DGC_MAX);
											uni.setStorageSync("NCG_PH_MIN",ret.data.NCG_PH_MIN);
											uni.setStorageSync("NCG_PH_MAX",ret.data.NCG_PH_MAX);
											uni.setStorageSync("NCG_SG_MIN",ret.data.NCG_SG_MIN);
											uni.setStorageSync("NCG_SG_MAX",ret.data.NCG_SG_MAX);							
								
							})
							.catch(() => {
								//this.loading = false;
								       		uni.setStorageSync("XY_GY_MIN",90);
											uni.setStorageSync("XY_GY_MAX",140);
											uni.setStorageSync("XY_DY_MIN",60);
											uni.setStorageSync("XY_DY_MAX",90);
											uni.setStorageSync("MB_MIN",60);
											uni.setStorageSync("MB_MAX",100);
											uni.setStorageSync("XT_CH_MIN",7);
											uni.setStorageSync("XT_CH_MAX",9.2);
											uni.setStorageSync("XT_KF_MIN",4);
											uni.setStorageSync("XT_KF_MAX",6.5);
											uni.setStorageSync("XY_MIN",95);
											uni.setStorageSync("XY_MAX",100);
											uni.setStorageSync("TW_MIN",36.5);
											uni.setStorageSync("TW_MAX",37);
											uni.setStorageSync("NS_UMOL_MIN",120);
											uni.setStorageSync("NS_UMOL_MAX",444);
											uni.setStorageSync("DGC_MIN",2.9);
											uni.setStorageSync("DGC_MAX",6);
											uni.setStorageSync("NCG_PH_MIN",5.4);
											uni.setStorageSync("NCG_PH_MAX",8.4);
											uni.setStorageSync("NCG_SG_MIN",1);
											uni.setStorageSync("NCG_SG_MAX",1.03);								
							});
			},			
			//跳转我的家人
			handleCstm(e){
				this.$mRouter.push({
					route: `/pages/user/family/family?source=1`
				});			
			},
			//跳转历史数据
			handleHistory($event,item){
				//console.log("typeof $event === 'string': " + typeof $event === 'string');
				let cstmId = this.cstmData.id || uni.getStorageSync('defaultCstmId') || this.userInfo.userId || 0
				if(typeof($event) =='string')
					this.$mRouter.push({
						route: `/pages/zhyl/health/healthTJChart?type=${item.title}&cstmId=${cstmId}`
					});
				else
					this.$mRouter.push({
						route: `/pages/zhyl/health/history?type=${item.title}&cstmId=${cstmId}`
					});		
			},			
			back() {				
				this.$mRouter.back();
			},
			// 数据初始化
			initData() {
				this.page = 1;
				this.userInfo =uni.getStorageSync('userInfo');
				this.getAddressList();
				this.getAddressDetail();
				this.getHealthParam();
			},
			// 获取用药提醒列表
			async getAddressList(type) {
				let params = {
				    cstmId: this.cstmData.id || uni.getStorageSync('defaultCstmId') || this.userInfo.userId || 0					
				}
				await this.$http
					.get(`${getTodayJkzsItem}`, params)
					.then(r => {
						//console.log("健康数据返回: " + JSON.stringify(r.data));
						this.loading = false;						
						if (type === 'refresh') {
							uni.stopPullDownRefresh();
						}
						
					  //清除前一次数据
					  this.info = []; 
					  
					  //健康数据						  
					  for(let i=0 ;i < 9 ;i++){
						  if(i===0){
							  let item = {};
							  item["extra"] = '趋势图';							  
							  item["title"] = '血压';	
							  item["images"] = 'hm1.png';
							  //item["texts"] = `高压：${r.data.xieyaHigh == 0 ? '--' : r.data.xieyaHigh} mmHg\n低压：${r.data.xieyaLow == 0 ? '--' : r.data.xieyaLow} mmHg\n脉搏：${r.data.maibo == 0 ? '--' : r.data.maibo} 次/分`;
							  let html = '';
							  if (r.data.xieyaHigh > uni.getStorageSync('XY_GY_MAX') || r.data.xieyaHigh < uni.getStorageSync('XY_GY_MIN') ) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">高压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.xieyaHigh == 0 ? '--' : r.data.xieyaHigh}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;							  
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">低压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xieyaLow == 0 ? '--' : r.data.xieyaLow}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">脉搏：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.maibo == 0 ? '--' : r.data.maibo}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 次/分</text></view>`;					
								
							  }else if(r.data.xieyaLow > uni.getStorageSync('XY_DY_MAX') || r.data.xieyaLow < uni.getStorageSync('XY_DY_MIN') ) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">高压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px; line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xieyaHigh == 0 ? '--' : r.data.xieyaHigh}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;							  
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">低压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.xieyaLow == 0 ? '--' : r.data.xieyaLow}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">脉搏：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.maibo == 0 ? '--' : r.data.maibo}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 次/分</text></view>`;								
								
							  }else if(r.data.maiboState != 0){
								  html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">高压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xieyaHigh == 0 ? '--' : r.data.xieyaHigh}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;
								  html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">低压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xieyaLow == 0 ? '--' : r.data.xieyaLow}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;
								  html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">脉搏：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.maibo == 0 ? '--' : r.data.maibo}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 次/分</text></view>`;								  
							  }else{
								  html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">高压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xieyaHigh == 0 ? '--' : r.data.xieyaHigh}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;
								  html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">低压：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xieyaLow == 0 ? '--' : r.data.xieyaLow}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmHg</text></view>`;
								  html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">脉搏：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.maibo == 0 ? '--' : r.data.maibo}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 次/分</text></view>`;
							  }							
								
							  item["texts"] = html;	  
							  item["tips"] = r.data.xueyagaugeTime;												
							  item["xieyaHigh"] = r.data.xieyaHigh;
							  item["xieyaLow"] = r.data.xieyaLow;
							  item["maibo"] = r.data.maibo;
							  item["xieyaHighState"] = r.data.xieyaHighState;
							  item["xieyaLowState"] = r.data.xieyaLowState;
							  item["maiboState"] = r.data.maiboState;
							  item["xueya_type"] = r.data.xueya_type;
							  item["xueyagaugeTime"] = r.data.xueyagaugeTime;
							  this.info.push(item);				  
						  }else if(i===1){
							  let item = {};
							  item["extra"] = '趋势图';							  
							  item["title"] = '血糖';	
							  item["images"] = 'hm2.png';	
							  //item["texts"] = `<text>餐前：</text> <text style="float:right">${r.data.kf_xietang==0?'--':r.data.kf_xietang} mol/l</text></br><text>餐后：</text> <text style="float:right">${r.data.ch_xietang==0?'--':r.data.ch_xietang} mol/l</text>`;
							 let html = '';														   
							 if(r.data.ch_xietang > uni.getStorageSync('XT_CH_MAX') || r.data.ch_xietang < uni.getStorageSync('XT_CH_MIN')) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">餐前：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;">${r.data.kf_xietang==0?'--':r.data.kf_xietang}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mol/l</text></view>`;							  
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">餐后：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.ch_xietang==0?'--':r.data.ch_xietang}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mol/l</text></view>`;																	
							}else if(r.data.kf_xietang > uni.getStorageSync('XT_CQ_MAX') || r.data.kf_xietang < uni.getStorageSync('XT_CQ_MIN')){
								html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">餐前：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.kf_xietang==0?'--':r.data.kf_xietang}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mol/l</text></view>`;
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">餐后：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.ch_xietang==0?'--':r.data.ch_xietang}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mol/l</text></view>`;
							}else{
								html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">餐前：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.kf_xietang==0?'--':r.data.kf_xietang}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mol/l</text></view>`;
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">餐后：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.ch_xietang==0?'--':r.data.ch_xietang}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mol/l</text></view>`;
							} 								
							  item["texts"] = html;	
									
							  item["tips"]	= 	r.data.xietanggaugeTime;					  
							  item["kf_xietang"] = r.data.kf_xietang;
							  item["ch_xietang"] = r.data.ch_xietang;
							  item["kf_xietang_state"] = r.data.kf_xietang_state;
							  item["ch_xietang_state"] = r.data.ch_xietang_state;
							  item["xietang_type"] = r.data.xietang_type;
							  item["xietanggaugeTime"] = r.data.xietanggaugeTime;
							  this.info.push(item);								  
							  
						  }else if(i===2){
							  let item = {};
							  item["extra"] = '趋势图';							  
							  item["title"] = '血氧';
							  item["images"] = 'hm7.png';						  
							  
							  //item["texts"] = `<text>血氧值：</text> <text style="float:right">${r.data.xy_oxygen==0?'--':r.data.xy_oxygen} %</text></br><text>脉搏率：</text> <text style="float:right">${r.data.xy_pulse==0?'--':r.data.xy_pulse} 次/分</text>`;
							 let html = '';														   
							 if(r.data.xy_oxygen > uni.getStorageSync('XY_MAX') || r.data.xy_oxygen < uni.getStorageSync('XY_MIN')) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">血氧值：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.xy_oxygen==0?'--':r.data.xy_oxygen}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> %</text></view>`;							  
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">脉搏率：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xy_pulse==0?'--':r.data.xy_pulse}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 次/分</text></view>`;																	
							}else{
								html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">血氧值：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xy_oxygen==0?'--':r.data.xy_oxygen}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> %</text></view>`;
								html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">脉搏率：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xy_pulse==0?'--':r.data.xy_pulse}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 次/分</text></view>`;
							} 								
							  item["texts"] = html;	
															
							  item["tips"]	= 	r.data.xieyanggaugeTime;															
							  item["xy_oxygen"] = r.data.xy_oxygen;
							  item["xy_pulse"] = r.data.xy_pulse;
							  item["xy_oxygen_state"] = r.data.xy_oxygen_state;
							  item["xy_pulse_state"] = r.data.xy_pulse_state;
							  item["xieyang_type"] = r.data.xieyang_type;
							  item["xieyanggaugeTime"] = r.data.xieyanggaugeTime;
							  this.info.push(item);								  
							  
						  }else if(i===3){
							  let item = {};
							  item["extra"] = '趋势图';
							  item["title"] = '胆固醇';
							  item["images"] = 'hm8.png';
							  //item["texts"] = `胆固醇：${r.data.xz_chol==0?'--':r.data.xz_chol} mmol`
							 let html = '';														   
							 if(r.data.xz_chol > uni.getStorageSync('DGC_MAX') || r.data.xz_chol < uni.getStorageSync('DGC_MIN')) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">胆固醇：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.xz_chol==0?'--':r.data.xz_chol}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmol</text></view>`;							  
							}else{
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">胆固醇：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.xz_chol==0?'--':r.data.xz_chol}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmol</text></view>`;							  
							} 								
							  item["texts"] = html;								  
							  item["tips"]	= r.data.xiezhigaugeTime;
							  item["xz_chol"] = r.data.xz_chol;
							  item["xiezhi_type"] = r.data.xiezhi_type;
							  item["xiezhigaugeTime"] = r.data.xiezhigaugeTime;
							  this.info.push(item);								  
							  
						  }else if(i===4){
							  let item = {};
							  item["extra"] = '趋势图';
							  item["title"] = '体质';
							  item["images"] = 'hm6.png';
							  //item["texts"] = `体重：${r.data.weight==0?'--':r.data.weight} kg\n身高：${r.data.height==0?'--':r.data.height} cm\nBMI：${r.data.bmi==0?'--':r.data.bmi}%`
							  let html = '';
								  html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">体重：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;">${r.data.weight==0?'--':r.data.weight}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 千克</text></view>`;
								  html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">身高：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;">${r.data.height==0?'--':r.data.height}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 厘米</text></view>`;
								  html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">BMI：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;">${r.data.bmi==0?'--':r.data.bmi}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> %</text></view>`;					
							  item["texts"] = html;							  
							  item["tips"] = 	r.data.tizhigaugeTime;								
							  item["bmi"] = r.data.bmi;
							  item["height"] = r.data.height;
							  item["weight"] = r.data.weight;
							  item["tizhi_type"] = 0;
							  item["tizhigaugeTime"] = r.data.tizhigaugeTime;							  
							  this.info.push(item);								  
							  
						  }else if(i===5){
							  let item = {};
							  item["extra"] = '趋势图';
							  item["title"] = '运动';
							  item["images"] = 'hm4.png';
							  //item["texts"] = `已走：${r.data.actual==0?'--':r.data.actual} 步\n目标：${r.data.target==0?'--':r.data.target} 步`
							  let html = '';
								  html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">已走：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;">${r.data.actual==0?'--':r.data.actual}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 步</text></view>`;
								  html +=`<view class="uni-flex uni-row" style="display: flex;"><text class="flex-item text-left" style="width: 33.3%;">目标：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;">${r.data.target==0?'--':r.data.target}</text><text class="flex-item text-right" style="width: 33.3%;text-align: right;"> 步</text></view>`;
							  item["texts"] = html;							  
							  item["tips"] =	r.data.sportgaugeTime;							
							  item["actual"] = r.data.actual;				 
							  item["yun_type"] = r.data.yun_type;							  
							  this.info.push(item);								  
							  
						  }else if(i===6){
							  let item = {};
							  item["extra"] = '趋势图';
							  item["title"] = '体温';
							  item["images"] = 'hm9.png';		
							  //item["texts"] = `体温：${r.data.am_tiweng==0?'--':r.data.am_tiweng} ℃`	
							 let html = '';														   
							 if(r.data.am_tiweng > uni.getStorageSync('TW_MAX') || r.data.am_tiweng < uni.getStorageSync('TW_MIN')) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">体温：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.am_tiweng==0?'--':r.data.am_tiweng}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> ℃</text></view>`;							  
							}else{
								html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">体温：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.am_tiweng==0?'--':r.data.am_tiweng}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> ℃</text></view>`;
							} 								
							  item["texts"] = html;								  
							  item["tips"] =r.data.tiwenggaugeTime;					
							  item["am_tiweng"] = r.data.am_tiweng;	
							  item["am_tiweng_state"] = r.data.am_tiweng_state;							  												   
							  item["tiweng_type"] = r.data.tiweng_type;
							  item["tiwenggaugeTime"] = r.data.tiwenggaugeTime;							  
							  this.info.push(item);								  
							  
						  }else if(i===7){
							  let item = {};
							  item["extra"] = '趋势图';
							  item["title"] = '尿酸';	
							  item["images"] = 'hm5.png';
							  //item["texts"] = `尿酸: ${r.data.uric_acid==0?'--':r.data.uric_acid} mmol`
							 let html = '';														   
							 if(r.data.uric_acid > uni.getStorageSync('NS_UMOL_MAX') || r.data.uric_acid < uni.getStorageSync('NS_UMOL_MIN')) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">尿酸：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.uric_acid==0?'--':r.data.uric_acid}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmol</text></view>`;							  
							}else{
								html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">尿酸：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.uric_acid==0?'--':r.data.uric_acid}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmol</text></view>`;
							} 								
							  item["texts"] = html;								  
							  item["tips"] =	r.data.niaosuangaugeTime;							
							  item["uric_acid"] = r.data.uric_acid;	
							  item["niaosuan_state"] = r.data.niaosuan_state;							  												   											   
							  item["niaosuan_type"] = 0;
							  item["niaosuangaugeTime"] = r.data.niaosuangaugeTime;							  
							  this.info.push(item);								  
							  
						  }else if(i===8){
							  let item = {};
							  item["extra"] = '趋势图';
							  item["title"] = '心率';	
							  item["images"] = 'hm3.png';
							  //item["texts"] = `心率：${r.data.avr_heartrate==0?'--':r.data.avr_heartrate} 次/分`
							 let html = '';														   
							 if(r.data.avr_heartrate > uni.getStorageSync('MB_MAX') || r.data.avr_heartrate < uni.getStorageSync('MB_MIN')) {
							    html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">心率：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:red;">${r.data.avr_heartrate==0?'--':r.data.avr_heartrate}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmol</text></view>`;							  
							}else{
								html += `<view class="uni-flex uni-row" style="display: flex;flex-direction: row;"><text class="flex-item text-left" style="width: 33.3%;">心率：</text> <text class="flex-item font-weight" style="width: 33.3%; font-size:18px;height: 18px;line-height: 18px; font-weight: bold;text-align:center;color:green;">${r.data.avr_heartrate==0?'--':r.data.avr_heartrate}</text> <text class="flex-item text-right" style="width: 33.3%;text-align: right;"> mmol</text></view>`;
							} 								
							  item["texts"] = html;								  
							  item["tips"] = r.data.ecggaugeTime;						
							  item["avr_heartrate"] = r.data.avr_heartrate;							  												   											   																																						 
							  item["avr_type"] = 0;
							  item["avrgaugeTime"] = r.data.ecggaugeTime;							  
							  this.info.push(item);								  							  
						  }
					  }	
					})
					.catch(e => {
						console.log("错误返回: " + JSON.stringify(e));
						this.loading = false;
						if (type === 'refresh') {
							uni.stopPullDownRefresh();
						}
					});
			},
			// 获取用药提醒
			async getAddressDetail() {
				var params = {
				   corpId: this.userInfo && this.userInfo.corpId,				
				   userId : this.userInfo && this.userInfo.userId,
				   cstmId:  this.cstmData.id || uni.getStorageSync('defaultCstmId')	|| this.userInfo.userId			   
			  }
				await this.$http
					.get(`${cstmDetail}`, params)
					.then(async r => {
						//console.log("个人信息: " + JSON.stringify(r.data));						
						this.cstmData = await r.data;
						this.loading = false;
					})
					.catch(() => {
						this.loading = false;
					});
			},				
			// 选择地址
			checkAddress(item) {
				if (parseInt(this.source, 10) === 1) {
					// this.$mHelper.prePage()获取上一页实例，在App.vue定义
					this.$mHelper.prePage().addressData = item;
					this.$mRouter.back();
				}
			}			
		}
	}
</script>

<style>
page{background-color: #f4f5f6;}
	/*样式的width和height一定要与定义的cWidth和cHeight相对应*/
	.qiun-charts {
		width: 750upx;
		height: 500upx;
		background-color: #FFFFFF;
	}
	
	.charts {
		width: 750upx;
		height: 500upx;
		background-color: #FFFFFF;
	}
	
.uni-flex {
	display: flex;
	flex-direction: row;
}
.uni-flex-item {
	flex: 1;
}
.uni-row {
	flex-direction: row;
}
.uni-column {
	flex-direction: column;
}
	
	.flex-item {
		width: 33.3%;
	    text-align: center;
	}
	.text-right{
		text-align: right;
	}
	.text-left{
		text-align: left;
	}
	.font-weight{
		font-weight: bold;
	}
	.flex-item-V {
		width: 100%;
		height: 150rpx;
		text-align: center;
		line-height: 150rpx;
	}
	.danger{
		color: red;
	}	
</style>
